package com.eaoa.query.pub;

import java.util.List;

import com.eaoa.base.EABaseQuery;
import com.eaoa.vo.pub.PubCity;


public class PubCityQuery extends EABaseQuery{

	public PubCityQuery() {
		super(PubCity.class);
	}
	
	public void setOrder(){
		setASCOrder("sort");
	}
	
	public void setIsLock(String val){
		setEQCondition("islock", val);
	}
	
	public void setCityno(Long val){
		setEQCondition("cityno", val);
	}
	
	public void setParentno(Long val){
		setEQCondition("parentno", val);
	}
	
	public void setCityname(String val){
		setLIKECondition("cityname", val);
	}
	
	public void setLayer(Long val){
		setEQCondition("layer", val);
	}
	
	public static PubCity loadByNo(Long cityno){
		if(cityno==null) return null;
		PubCityQuery query = new PubCityQuery();
		query.setCityno(cityno);
		query.execute();
		if(query.getResults().size()!=1){
			return null;
		}
		return (PubCity)query.getResults().get(0);
	}
	
	public static List getCitys(Long cityno, Long layer){
		if(cityno==null)return null;
		PubCityQuery cityQuery = new PubCityQuery();
		cityQuery.setIsLock("N");
		cityQuery.setParentno(cityno);
		cityQuery.setLayer(layer);	
		cityQuery.noCheckOutOfMemory();
		cityQuery.setOrder();
		cityQuery.execute();
		return cityQuery.getResults();
	}
	
}
